// void, Obj me, Obj wall_gate

Unit this;
Obj u;
point dirpt, dirpt1;
int k;

Sleep(rand(100)+30);
this = me.AsUnit();
dirpt = wall_gate.AsBuilding().GetPoint(8, 0);
dirpt1 = dirpt;
k = 0;

while (1) {
	u = .BestTargetInSquadSight();
	while (1) {
		if (!u.IsAlive()) break;
		if (!.IsValidTarget(u)) break;
		if (!.InRange(u)) break;
		if(.Attack(u)){
            Sleep(70);
			//######### MODUL GUARDIAN 1 START ###########
			if(u.AsUnit.IsHeirOf("EGuardian")){
				if(u.AsUnit.command != "engage" &&
				   u.AsUnit.command != "engage_unit_type"){
					if(rand(100) > 10){
						if(!u.AsUnit.BestTargetForPos.IsValid)
						if(u.AsUnit.health < u.AsUnit.maxhealth){
							u.AsUnit.Heal(500);
						}
					}
				}
			}
			//######### MODUL GUARDIAN 1 END ###########
		}
		dirpt1 = dirpt;
		k = 0;
	}
	.Stop(1000);
	.Face(.pos - dirpt1);
	Sleep(rand(200) + 600);
	if (k < 20) {
		dirpt1 = dirpt1 + Point(rand(51)-25, rand(51)-25);
		k += 1;
	} else {
		dirpt1 = dirpt;
		k = 0;
	}
}
 
